# Copyright (C) Nicola Bizzoca   2006/2007  <hannibal_smith@users.sourceforge.net>
# Copyright (C) Simone Economo   2006/2007  <ekoes@users.sourceforge.net>
# 
#	This file is part of Absynth-FTP.
#
#	Absynth-FTP is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 3 of the License, or
#	(at your option) any later version.
#
#	Absynth-FTP is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program.  If not, see <http://www.gnu.org/licenses/>.

from lib.GNOMEConf import GtkConfig
from engine import Widgets
from abcommon import *

class UI(Widgets):
	def __init__(self):
		Widgets.__init__(self)
		self.conf = GtkConfig()
		self.__widget = self.XMLtree.getWidget(conf.WINDOW_TYPE)
		self.__widget.show_all()
		self.__set(
				"%s %s" % (self.conf.get("appName"), self.conf.get("appVersion")),
				conf.DATA_DIR + "/img/logo_minimal.png")
		
	def __set(self, title, icon):
		self.__widget.activate_default()
		self.__widget.set_title(title)
		self.__widget.set_icon_from_file(icon)
 		
 	def _loadAboutDialog(self, *args):
 		Widgets.selectWidget("AboutDialog").UI()
 		
 	def getFTPConnectionData(self, *args):
 		self.__getWidgets = {
			"hostname":	self.XMLtree.getWidget("HostnameBox"),
			"username": self.XMLtree.getWidget("UsernameBox"),
			"password": self.XMLtree.getWidget("PasswordBox")
		}
 		self.__connectionData = {
			"hostname":	self.__getWidgets["hostname"].get_text(),
			"username":	self.__getWidgets["username"].get_text(),
			"password":	self.__getWidgets["password"].get_text()
		}
 		return self.__connectionData
 	
 	def hint(self, mode):
 		self.__widget.set_urgency_hint(mode)